import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ContentCategoryVO, ContentCategoryForm, ContentCategoryQuery } from '@/api/business/contentCategory/types';

/**
 * 查询内容分区列表
 * @param query
 * @returns {*}
 */

export const listContentCategory = (query?: ContentCategoryQuery): AxiosPromise<ContentCategoryVO[]> => {
  return request({
    url: '/business/contentCategory/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询内容分区详细
 * @param id
 */
export const getContentCategory = (id: string | number): AxiosPromise<ContentCategoryVO> => {
  return request({
    url: '/business/contentCategory/' + id,
    method: 'get'
  });
};

/**
 * 新增内容分区
 * @param data
 */
export const addContentCategory = (data: ContentCategoryForm) => {
  return request({
    url: '/business/contentCategory',
    method: 'post',
    data: data
  });
};

/**
 * 修改内容分区
 * @param data
 */
export const updateContentCategory = (data: ContentCategoryForm) => {
  return request({
    url: '/business/contentCategory',
    method: 'put',
    data: data
  });
};

/**
 * 删除内容分区
 * @param id
 */
export const delContentCategory = (id: string | number | Array<string | number>) => {
  return request({
    url: '/business/contentCategory/' + id,
    method: 'delete'
  });
};
